using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using NUlid;
using StudentVideo.Shared.Enums;

namespace StudentVideo.Data.Entities;


/// <summary>
/// 管理员用户
/// </summary>
[Table("user")]
public class UserEntity: BaseEntity {
   [Key]
   [Column(Order = 1, TypeName = "varchar(50)")]
   public override string Id { get; set; } = Ulid.NewUlid().ToString();

   /// <summary>
   /// 用户名
   /// </summary>
   [MaxLength(15)]
   public required string Username { get; set; }

   /// <summary>
   /// 昵称
   /// </summary>
   [MaxLength(20)]
   public string? Nickname { get; set; }

   /// <summary>
   /// 密码
   /// </summary>
   [MaxLength(50)]
   public required string Password { get; set; } = null!;

   /// <summary>
   /// 性别
   /// </summary>
   [Column(TypeName = "tinyint")]
   public GenderEnum Gender { get; set; } = GenderEnum.Other;

   /// <summary>
   /// 启用状态
   /// </summary>
   public bool Enable { get; set; } = true;

   /// <summary>
   /// 密码加密段
   /// </summary>
   public required byte[] Salt { get; set; }

   /// <summary>
   /// 头像
   /// </summary>
   [MaxLength(150)]
   public string? Avatar { get; set; }

   [InverseProperty(nameof(UserRoleMapEntity.User))]
   public ICollection<UserRoleMapEntity>? UserRoleMaps { get; set; }
}
